<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>用户注册</title>
<style>
.p {
	color: red;
	margin-left: 20px;
	display: inline-block;
}

.c {
	color: red;
	margin-left: 4px;
	display: inline-block;
}

.l {
	font-size: 18px;
}

.d {
	height: 35px;
	width: 300px;
	display: inline;
}

.i {
	height: 30px;
	width: 300px;
}
</style>
<script type="text/javascript">
    var path = window.document.location.href;
	var pathName = window.document.location.pathname;
	var hostPath = path.substring(0, path.indexOf(pathName));
	var projectName = pathName.substring(0, pathName.substr(1).indexOf("/") + 1);
	document.write('<scr' + 'ipt src="' + projectName + '/js/html/header.js"></scr'+'ipt>');
</script>
</head>
<body>
	<div style="height: 80px;"></div>
	<form id="registerForm">
		<div
			style="width: 500px; height: 400px; position: fixed; left: 50%; top: 50%; z-index: 11; margin: -200px 0 0 -250px;">
			<div style="font-size: 28px;">注册新用户</div>
			<br/> 
			<span class="p">*</span> <label for="loginName" class="l">登陆名:</label>
			<div style="height: 35px; width: 300px; position: relative; display: inline;">
				<input id="loginName" type="text" style="height: 30px; width: 250px; padding-right: 50px;"/> 
				<span style="position: absolute; right: 18px; top: 2px; background-image: url(user.ico); height: 16px; width: 16px; display: inline-block;"></span>
			</div>
			<br/> 
			<br/> 
				<span class="c">*</span> <label for="login_password" class="l">登录密码:</label>
			<div class="d">
				<input id="passWord" type="text" class="i">
			</div>
			<br/> 
			<br/> 
				<span class="c">*</span> <label	for="confirm_password" class="l">确认密码:</label>
			<div class="d">
				<input id="confirm_password" type="text" class="i">
			</div>
			<br/> 
			<br/> 
			<span class="p">&nbsp;&nbsp;</span> <label for="empNo" class="l">员工号:</label>
			<div class="d">
				<input id="empNo" type="text" class="i">
			</div>
			<br/> 
			<br/> 
			<span class="p">&nbsp;&nbsp;</span> <label for="phonenumber" class="l">手机号:</label>
			<div class="d">
				<input id="phonenumber" type="text" class="i">
			</div>
			<br/>
			<br/>
			<input type="checkbox" name="agree"	style="margin-left: 100px; display: inline-block;" value="1" /> 
			<span style="font-size: 10px;">同意用户注册协议</span> 
			<br/> <br/>
			<input type="button" onclick="submitRegister()" value="注册"  style="margin-left: 100px; height: 30px; width: 300px; background-color: red; display: inline-block;" />
		</div>
	</form>
	<script>
		function console(){
			$("#loginName").attr("value","");
			$("#passWord").attr("value","");
			$("#userName").attr("value","");
			$("#empNo").attr("value","");
			$("#email").attr("value","");
		}
		
		function submitRegister() {
			var loginName  = $("#loginName").val();
			if(loginName==""){
				$.messager.alert('警告','请输入登录用户名！');
			}
			
			var passWord  = $("#passWord").val();
			var confirmPassword = $("#confirm_password").val();
			
			if(passWord=="" || confirmPassword==""){
				$.messager.alert('警告','要素请填写完整！');
			}else if(passWord != confirmPassword){
				$.messager.alert('警告','两次输入的密码不一致，请检查！');
			}
			
			$.ajax({
				type : "POST",
				url : projectName+"/index/register",						
				data: $('#registerForm').serialize(),
				dataType : "json",
				success : function(data) {
					if (!data.success) {
						alert(data.message);
						return;
					}
					if (data != null) {
						$.messager.alert('提示','注册成功！');
						console();
					}
				},
				error:function(err, status){
					errorMsgAlert(err);
				}
			});
			
		}

	</script>
</body>
</html>